from django.db import models

# Create your models here.

class userGroup(models.Model):
    gid = models.AutoField(primary_key=True)
    userGroupName = models.CharField(max_length=20,unique=True)
    usersNum = models.IntegerField(default=0)
    userGroupDes = models.CharField(max_length=500)
    ctime = models.DateTimeField(auto_now_add=True,null=True)
    uptime = models.DateTimeField(auto_now=True,null=True)
    def __str__(self):
        return self.userGroupName
    class Meta:
        verbose_name = '用户组'
        verbose_name_plural = '用户组'
class userInfo(models.Model):
    uid = models.AutoField(primary_key=True)
    userName = models.CharField(max_length=50,unique=True)
    userNameHuman = models.CharField(max_length=50)
    userEmail = models.EmailField()
    userPassword = models.CharField(max_length=20)
    user_tyep_choices = (
        (0,'普通用户'),
        (1,'管理员'),
    )
    userType = models.IntegerField(choices=user_tyep_choices,default=1)
    userValidity = models.CharField(max_length=30)  #有效期，
    userPermission = models.CharField(max_length=1000,null=True,blank=True)
    user_is_active = (
        (0,'已启用'),
        (1,'已停用'),
    )
    userIsActive = models.IntegerField(choices=user_is_active,default=0)
    usergroup = models.ForeignKey(userGroup)
    ctime = models.DateTimeField(auto_now_add=True,null=True)
    uptime = models.DateTimeField(auto_now=True,null=True)
    def __str__(self):
        return self.userName
    class Meta:
        verbose_name = '用户信息'
        verbose_name_plural = '用户信息'
